BASE_DIR    	=   source
SOCK_DIR    	=   socket
TCP_SOCK_DIR	=	tcp
TOOLS           =   tools
LOG             =   log
#fix me, error in building
#all: buildall tcpClient tcpServer done
#all: buildall socket done
all: buildall done

buildall:
	@echo " "
	@echo "****************************************"
	@echo "*******  Building source codes  ********"
	@echo "****************************************"
	@echo " "
	@echo "******   Building Dependency      ******"
	@echo " "
	#(cd ./$(TOOLS)/$(LOG)/; $(MAKE))
	@echo " "
	@echo "******  Building Base Application  ******"
	@echo " "
	(cd ./$(BASE_DIR)/; $(MAKE))
	@echo " "

socket:	info udpSocketApp tcpSocketApp

info:
	@echo "*****************************************"
	@echo "***** Building socket Application  ******"
	@echo "*****************************************"
	@echo " "

udpSocketApp:
	@echo " "
	@echo "******   Building UDP socket App   ******"
	@echo " "
	(cd ./$(BASE_DIR)/$(SOCK_DIR); $(MAKE))

tcpSocketApp:
	@echo " "
	@echo "******   Building TCP socket App   ******"
	@echo " "
	(cd ./$(BASE_DIR)/$(SOCK_DIR)/$(TCP_SOCK_DIR); $(MAKE))
	
done:
	@echo " "
	@echo "*****************************************"
	@echo "*******     build successful     ********"
	@echo "*****************************************"
	@echo " "

clean:
	@echo " "
	@echo "*****************************************"
	@echo "*******     Invoking Cleanup     ********"
	@echo "*****************************************"
	@echo " "
	(cd $(BASE_DIR); $(MAKE) clean)
	@echo " "
	@echo "*****************************************"
	@echo "*******       Cleanup done       ********"
	@echo "*****************************************"
	@echo " "

cleanapp:
	@echo " "
	@echo "*****************************************"
	@echo "******* Application Only Cleanup ********"
	@echo "*****************************************"
	@echo " "
	(cd $(BASE_DIR); $(MAKE) cleanapp)
	@echo " "
	@echo "*****************************************"
	@echo "******* Application Cleanup done ********"
	@echo "*****************************************"
	@echo " "

distclean:
	@echo " "
	@echo "*****************************************"
	@echo "******* Application Only Cleanup ********"
	@echo "*****************************************"
	@echo " "
	(cd $(BASE_DIR); $(MAKE) distclean)
	@echo " "
	@echo "*****************************************"
	@echo "******* Application Cleanup done ********"
	@echo "*****************************************"

